<template>
	<view class="bottom_btn">
		<!-- 物流发货-全款支付订单 -->
		<template v-if="item.send_type == 0 && item.is_prepay == 0">
			<!-- 正常状态 -->
			<template v-if="item.refundstatus == 0 && item.refund.length == 0">
				<view v-if="(item.state == 1 || item.state == 2) && item.wedding.u_type != 3 && item.wedding.u_type != 1" class="b" @click.stop="cancel(item)">取消订单</view>
				<template v-if="item.state == 1 && !item.paymenttime">
					<!-- 置灰按钮 -->
					<view :class="['r', { disabled: item.can_pay == 0 || item.pay_action == 0 }]" @click.stop="payment(item)">去支付</view>
				</template>
				<!-- 物流发货全款支付  还没有确认收货时，是没有“申请售后”按钮的。 -->
				<view v-if="item.state == 7 || item.state == 6" class="b" @click.stop="zaicigoumai(item)">再次购买</view>
				<view v-if="item.state == 4" class="b" @click.stop="shohou(item.id)">申请售后</view>
				<view v-if="item.state == 3" class="r" @click.stop="confirm(item.id)">确认收货</view>
				<view v-if="item.state == 4" class="b" @click.stop="goComment(item)">评价晒单</view>
			</template>
			<!-- 支付取消订单 -->
			<template v-if="item.refundstatus != 0"></template>
			<!-- 申请退货订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 0">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
			</template>
			<!-- 申请换货订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 1">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
				<view v-if="item.refund.refund_state == 2 && item.refund.state != 4" class="r" @click.stop="confirm2(item)">确认收货</view>
			</template>
			<!-- 申请维修订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 2">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
				<view v-if="item.refund.refund_state == 2 && item.refund.state != 4" class="r" @click.stop="confirm2(item)">确认收货</view>
			</template>
		</template>
		<!-- 物流发货-定金支付订单 -->
		<template v-if="item.send_type == 0 && item.is_prepay == 1">
			<!-- 正常状态 -->

			<template v-if="item.refundstatus == 0 && item.refund.length == 0">
				<view v-if="(item.state == 1 && !(item.paymenttime > 0)) || (item.state == 1 && item.paymenttime > 0)" class="b" @click.stop="cancel(item)">取消订单</view>
				<!-- 定金支付订单是在线上收取，不是线上再支付一次。这里待付尾未订单这里没有“去支付”按钮。 -->
				<block v-if="item.state == 1 && !item.paymenttime">
					<view :class="['r', { disabled: item.can_pay == 0 || item.pay_action == 0 }]" @click.stop="payment(item)">支付定金</view>
				</block>
				<view v-if="item.state == 7 || item.state == 6" class="b" @click.stop="zaicigoumai(item)">再次购买</view>
				<view v-if="item.state == 4" class="b" @click.stop="shohou(item.id)">申请售后</view>
				<view v-if="item.state == 3" class="r" @click.stop="confirm(item.id)">确认收货</view>
				<view v-if="item.state == 4" class="b" @click.stop="goComment(item)">评价晒单</view>
			</template>
			<!-- 支付取消订单 -->
			<template v-if="item.refundstatus != 0"></template>
			<!-- 申请退货订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 0">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
			</template>
			<!-- 申请换货订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 1">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
				<view v-if="item.refund.refund_state == 2 && item.refund.state != 4" class="r" @click.stop="confirm2(item)">确认收货</view>
			</template>
			<!-- 申请维修订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 2">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
				<view v-if="item.refund.refund_state == 2 && item.refund.state != 4" class="r" @click.stop="confirm2(item)">确认收货</view>
			</template>
		</template>
		<!-- 商家配送-全款支付订单 -->
		<template v-if="item.send_type == 1 && item.is_prepay == 0">
			<!-- 正常状态 -->
			<template v-if="item.refundstatus == 0 && item.refund.length == 0">
				<view v-if="(item.state == 1 || item.state == 2) && item.wedding.u_type != 3 && item.wedding.u_type != 1" class="b" @click.stop="cancel(item)">取消订单</view>
				<template v-if="item.state == 1 && !item.paymenttime">
					<!-- 置灰按钮 -->
					<view :class="['r', { disabled: item.can_pay == 0 || item.pay_action == 0 }]" @click.stop="payment(item)">去支付</view>
				</template>
				<!-- <view v-if="item.state>2&&item.state!=5&&item.state!=7&&item.is_refund==1" class="b"
					@click.stop="shohou(item.id)">
					申请售后
				</view> -->
				<!-- 在商家配送-全款支付中，还没有确认收货的状态下，客户端是没有“申请售后”按钮 的。 -->
				<view v-if="item.state == 4" class="b" @click.stop="shohou(item.id)">申请售后</view>
				<view v-if="item.state == 3" class="r" @click.stop="confirm(item.id)">确认收货</view>
				<view v-if="item.state == 4" class="b" @click.stop="goComment(item)">评价晒单</view>
				<view v-if="item.state == 7 || item.state == 6" class="b" @click.stop="goAdd(item)">再次购买</view>
			</template>
			<!-- 支付取消订单 -->
			<template v-if="item.refundstatus != 0"></template>
			<!-- 申请退货订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 0">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
			</template>
			<!-- 申请换货订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 1">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
				<view v-if="item.refund.refund_state == 2 && item.refund.state != 4" class="r" @click.stop="confirm2(item)">确认收货</view>
			</template>
			<!-- 申请维修订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 2">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
				<view v-if="item.refund.refund_state == 2 && item.refund.state != 4" class="r" @click.stop="confirm2(item)">确认收货</view>
			</template>
		</template>
		<!-- 商家配送-定金支付订单 -->
		<template v-if="item.send_type == 1 && item.is_prepay == 1">
			<!-- 正常状态 -->
			<template v-if="item.refundstatus == 0 && item.refund.length == 0">
				<view v-if="(item.state == 1 && !(item.paymenttime > 0)) || (item.state == 1 && item.paymenttime > 0)" class="b" @click.stop="cancel(item)">取消订单</view>
				<!-- 定金支付订单是在线上收取，不是线上再支付一次。这里待付尾未订单这里没有“去支付”按钮。 -->
				<block v-if="item.state == 1 && !item.paymenttime">
					<view :class="['r', { disabled: item.can_pay == 0 || item.pay_action == 0 }]" @click.stop="payment(item)">支付定金</view>
				</block>
				<!-- <view v-if="item.state>2&&item.state!=5&&item.state!=7&&item.is_refund==1" class="b"
					@click.stop="shohou(item.id)">
					申请售后
				</view> -->
				<view v-if="item.state == 7 || item.state == 6" class="b" @click.stop="zaicigoumai(item)">再次购买</view>
				<view v-if="item.state == 4" class="b" @click.stop="shohou(item.id)">申请售后</view>
				<view v-if="item.state == 3" class="r" @click.stop="confirm(item.id)">确认收货</view>
				<view v-if="item.state == 4" class="b" @click.stop="goComment(item)">评价晒单</view>
				<view v-if="item.state == 6" class="b" @click.stop="goAdd(item)">再次购买</view>
			</template>
			<!-- 支付取消订单 -->
			<template v-if="item.refundstatus != 0"></template>
			<!-- 申请退货订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 0">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
			</template>
			<!-- 申请换货订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 1">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
				<view v-if="item.refund.refund_state == 2 && item.refund.state != 4" class="r" @click.stop="confirm2(item)">确认收货</view>
			</template>
			<!-- 申请维修订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 2">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
				<view v-if="item.refund.refund_state == 2 && item.refund.state != 4" class="r" @click.stop="confirm2(item)">确认收货</view>
			</template>
		</template>
		<!-- 到店自提-全款支付订单 -->
		<template v-if="item.send_type == 2 && item.is_prepay == 0">
			<!-- 正常状态 -->
			<template v-if="item.refundstatus == 0 && item.refund.length == 0">
				<view v-if="(item.state == 1 || item.state == 2) && item.wedding.u_type != 3 && item.wedding.u_type != 1" class="b" @click.stop="cancel(item)">取消订单</view>
				<template v-if="item.state == 1 && !item.paymenttime">
					<!-- 置灰按钮 -->
					<view :class="['r', { disabled: item.can_pay == 0 || item.pay_action == 0 }]" @click.stop="payment(item)">去支付</view>
				</template>
				<!-- <view v-if="item.state>2&&item.state!=5&&item.state!=7&&item.is_refund==1" class="b"
					@click.stop="shohou(item.id)">
					申请售后
				</view> -->
				<view v-if="item.state == 7 || item.state == 6" class="b" @click.stop="zaicigoumai(item)">再次购买</view>
				<view v-if="item.state == 4" class="b" @click.stop="shohou(item.id)">申请售后</view>
				<view v-if="item.state == 3" class="r" @click.stop="confirm(item.id)">确认收货</view>
				<view v-if="item.state == 4" class="b" @click.stop="goComment(item)">评价晒单</view>
				<view v-if="item.state == 6" class="b" @click.stop="goAdd(item)">再次购买</view>
			</template>
			<!-- 支付取消订单 -->
			<template v-if="item.refundstatus != 0"></template>
			<!-- 申请退货订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 0">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
			</template>
			<!-- 申请换货订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 1">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
				<view v-if="item.refund.refund_state == 2 && item.refund.state != 4" class="r" @click.stop="confirm2(item)">确认收货</view>
			</template>
			<!-- 申请维修订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 2">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
				<view v-if="item.refund.refund_state == 2 && item.refund.state != 4" class="r" @click.stop="confirm2(item)">确认收货</view>
			</template>
		</template>
		<!-- 到店自提-定金支付订单 -->
		<template v-if="item.send_type == 2 && item.is_prepay == 1">
			<!-- 正常状态 -->
			<template v-if="item.refundstatus == 0 && item.refund.length == 0">
				<view v-if="(item.state == 1 && !(item.paymenttime > 0)) || (item.state == 1 && item.paymenttime > 0)" class="b" @click.stop="cancel(item)">取消订单</view>
				<!-- 定金支付订单是在线上收取，不是线上再支付一次。这里待付尾未订单这里没有“去支付”按钮。 -->
				<block v-if="item.state == 1 && !item.paymenttime">
					<view :class="['r', { disabled: item.can_pay == 0 || item.pay_action == 0 }]" @click.stop="payment(item)">支付定金</view>
				</block>
				<!-- <view v-if="item.state>2&&item.state!=5&&item.state!=7&&item.is_refund==1" class="b"
					@click.stop="shohou(item.id)">
					申请售后
				</view> -->
				<view v-if="item.state == 7 || item.state == 6" class="b" @click.stop="zaicigoumai(item)">再次购买</view>
				<view v-if="item.state == 4" class="b" @click.stop="shohou(item.id)">申请售后</view>
				<view v-if="item.state == 3" class="r" @click.stop="confirm(item.id)">确认收货</view>
				<view v-if="item.state == 4" class="b" @click.stop="goComment(item)">评价晒单</view>
				<view v-if="item.state == 6" class="b" @click.stop="goAdd(item)">再次购买</view>
			</template>
			<!-- 支付取消订单 -->
			<template v-if="item.refundstatus != 0"></template>
			<!-- 申请退货订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 0">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
			</template>
			<!-- 申请换货订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 1">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
				<view v-if="item.refund.refund_state == 2 && item.refund.state != 4" class="r" @click.stop="confirm2(item)">确认收货</view>
			</template>
			<!-- 申请维修订单 -->
			<template v-if="item.refund.length != 0 && item.refund.opre_type == 2">
				<view v-if="item.refund.state == 1 && item.refund.refund_state == 0" class="r" @click.stop="querentuihuo(item)">确认退货</view>
				<view v-if="item.refund.offline_time > 0 && !(item.refund.offline_sure_time > 0)" class="r" @click.stop="shoushangjiazishoukuan(item)">收商家自收款</view>
				<view v-if="item.refund.refund_state == 2 && item.refund.state != 4" class="r" @click.stop="confirm2(item)">确认收货</view>
			</template>
		</template>
		<!-- 取消订单弹窗 -->
		<uni-popup ref="cancelOrder" type="center">
			<view class="tips2">
				<view class="title">提示</view>
				<view class="content">{{ popupContent }}</view>
				<view class="btn-group">
					<view class="btn cancel" @click.stop="cancelOrder(0)">取消</view>
					<view class="btn confirm" @click.stop="cancelOrder(1)">确定</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
export default {
	props: {
		item: {
			default: {},
			type: Object
		}
	},
	data() {
		return {
			orderData: {},
			popupContent: '',
			confirmType: 0
		};
	},
	methods: {
		// 点击再次购买
		zaicigoumai(item) {
			let ind = item.goods[0].goods_id;
			uni.redirectTo({
				url: '/pages/filePages/goodsDetail/goodsDetail?id=' + ind + '&type=0'
			});
		},
		//刷新列表
		refer(data) {
			this.$emit('refresh', data);
		},
		//收商家自收款
		shoushangjiazishoukuan(item) {
			this.orderData = item;
			this.popupContent = '是否收到非平台上支付的货款';
			this.confirmType = 2;
			this.$refs.cancelOrder.open();
		},
		//收商家自收款接口请求
		shoushangjiazishoukuanAPI() {
			let that = this;
			let item = this.orderData;
			uni.showLoading({
				title: ''
			});
			this.$request({
				url: 'manage/refund_second_sure',
				method: 'POST',
				data: {
					id: item.refund.id
				}
			}).then((res) => {
				if (res.data.code == 1) {
					that.$wanlshop.msg('操作成功！');
					that.refer(item);
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					});
				}
			});
		},
		//确认退货
		querentuihuo(item) {
			this.orderData = item;
			this.popupContent = '确认退货吗';
			this.confirmType = 3;
			this.$refs.cancelOrder.open();
		},
		// 确认退货接口请求
		querentuihuoAPI() {
			let that = this;
			let item = this.orderData;
			uni.showLoading({
				title: ''
			});
			this.$request({
				url: 'refund/toExpress',
				method: 'POST',
				data: {
					id: item.refund.id,
					express_name: '',
					express_no: ''
				}
			}).then((res) => {
				if (res.data.code == 1) {
					that.$wanlshop.msg('操作成功！');
					that.refer(item);
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					});
				}
			});
		},
		// 确认退货
		submitWl() {
			if (this.kdmc == '') {
				this.$wanlshop.msg('请填写快递名称');
			} else if (this.wlxx == '') {
				this.$wanlshop.msg('请填写物流信息');
			} else {
				this.$request({
					url: 'refund/toExpress',
					method: 'POST',
					data: {
						id: this.refundId,
						express_name: this.kdmc,
						express_no: this.wlxx
					}
				}).then((res) => {
					if (res.data.code == 1) {
						this.$wanlshop.msg('提交成功');
						this.$refs.popup.close();
					}
				});
			}
		},
		logistics(id) {
			this.refundId = id;
			this.$refs.popup.open('bottom');
		},
		shohou(id) {
			uni.navigateTo({
				url: '/pages/filePages/salesType/salesType?id=' + id
			});
		},
		goAdd(item) {
			let type = 0;
			if (item.order_type == 'goods') {
				type = 0;
			} else {
				type = 1;
			}
			uni.navigateTo({
				url: '/pages/filePages/goodsDetail/goodsDetail?id=' + item.goods[0].goods_id + '&type=' + type
			});
		},
		goComment(item) {
			uni.navigateTo({
				url: '/pages/filePages/comment/comment?id=' + item.id
			});
		},
		// 获取订单列表
		getOrderList() {
			let that = this;
			uni.showLoading({
				title: '加载中'
			});
			this.$request({
				url: 'order/getOrderList',
				data: {
					state: that.listIndex,
					page: that.page
				}
			}).then((res) => {
				const { code, data, msg } = res.data;
				if (code == 1) {
					that.totalNum = data.last_page;
					if (that.page == 1) {
						that.listData = data.data;
					} else {
						if (data.data.length > 0) {
							that.listData = [...that.listData, ...data.data];
						} else {
							that.page--;
						}
					}
				} else {
					uni.showToast({
						title: msg,
						icon: 'error'
					});
				}
				uni.hideLoading();
			});
		},
		// 普通商品去支付传id
		payment(data) {
			if (data.can_pay == 0) {
				return uni.showToast({
					title: '当前订单暂不能支付',
					icon: 'none',
					mask: true
				});
			}
			if (!data.paymenttime && data.pay_action === 0) {
				uni.showToast({
					title: data.remarks,
					icon: 'none',
					duration: 2000
				});
				return;
			}
			let that = this;
			uni.showLoading({
				title: '支付中'
			});
			uni.login({
				provider: 'weixin',
				success: function (res) {
					that.paymentOption(data, res.code);
				}
			});
		},
		// 支付操作接口请求
		paymentOption(data, code) {
			const that = this;
			this.$request({
				url: 'pay/payment',
				method: 'POST',
				data: {
					order_id: data.id,
					order_type: data.order_type,
					type: 'wechat',
					method: 'miniapp',
					code
				}
			}).then((res) => {
				if (res.data.code == 1) {
					that
						.$wx_pay(res.data.data)
						.then((res) => {
							uni.showToast({
								title: '支付成功',
								icon: 'success',
								duration: 2000
							});
							that.refer(data);
						})
						.catch((err) => {
							uni.showToast({
								title: '取消支付',
								icon: 'none',
								duration: 2000
							});
						});
				} else {
					uni.showToast({
						title: res.data.msg
					});
				}
				uni.hideLoading();
			});
		},
		// 取消订单提示
		cancel(item) {
			this.orderData = item;
			this.popupContent = '确认取消订单？';
			this.confirmType = 1;
			this.$refs.cancelOrder.open();
		},
		// 取消订单操作
		cancelOrder(type) {
			if (type) {
				if (this.confirmType == 1) {
					this.cancelOrderAPI();
				} else if (this.confirmType == 2) {
					this.shoushangjiazishoukuanAPI();
				} else if (this.confirmType == 3) {
					this.querentuihuoAPI();
				} else if (this.confirmType == 4) {
					this.confirmAPI();
				} else if (this.confirmType == 5) {
					this.confirm2API();
				}
			} else {
				this.orderData = {};
				this.confirmType = 0;
				this.popupContent = '';
				this.$refs.cancelOrder.close();
			}
		},
		// 取消订单接口
		cancelOrderAPI() {
			let that = this;
			let item = this.orderData;
			uni.showLoading({
				title: '取消中'
			});
			// 支付前
			this.$request({
				url: 'order/cancelOrder',
				method: 'POST',
				data: {
					id: item.id
				}
			}).then((res) => {
				uni.hideLoading();
				if (res.data.code == 1) {
					item.is_cancel = true;
					that.refer(item);
					uni.showToast({
						title: '取消成功',
						icon: 'none',
						duration: 2000
					});
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none',
						duration: 2000
					});
				}
				this.orderData = {};
				this.confirmType = 0;
				this.popupContent = '';
				this.$refs.cancelOrder.close();
			});
		},
		// 确认收货传id
		confirm(id) {
			this.orderData = { id: id };
			this.popupContent = '确认收到货了吗';
			this.confirmType = 4;
			this.$refs.cancelOrder.open();
		},
		//  确认收货接口请求
		confirmAPI() {
			let that = this;
			let item = this.orderData;
			uni.showLoading({
				title: '数据提交中···'
			});
			this.$request({
				url: 'order/confirmOrder',
				method: 'POST',
				data: {
					id: item.id
				}
			}).then((res) => {
				if (res.data.code == 1) {
					that.$wanlshop.msg('收货成功');
					that.refer(item);
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					});
				}
				this.orderData = {};
				this.confirmType = 0;
				this.popupContent = '';
				this.$refs.cancelOrder.close();
			});
		},
		// 售后确认收货
		confirm2(item) {
			this.orderData = item;
			this.popupContent = '确认收到货了吗';
			this.confirmType = 5;
			this.$refs.cancelOrder.open();
		},
		//售后确认收货接口请求
		confirm2API() {
			let that = this;
			let item = this.orderData;
			uni.showLoading({
				title: ''
			});
			this.$request({
				url: 'refund/refund_sure',
				method: 'POST',
				data: {
					id: item.refund.id
				}
			}).then((res) => {
				if (res.data.code == 1) {
					that.$wanlshop.msg('收货成功');
					that.refer(item);
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					});
				}
			});
		}
	}
};
</script>

<style scoped lang="scss">
.bottom_btn {
	margin-top: 24upx;
	display: flex;
	align-items: center;
	justify-content: flex-end;
}
.b {
	min-width: 156rpx;
	padding: 14rpx 30rpx;
	border-radius: 30rpx;
	border: 1rpx solid #ccc;
	font-size: 22rpx;
	color: #333;
	margin-left: 12rpx;
	box-sizing: border-box;
}

.r {
	min-width: 156rpx;
	padding: 14rpx 30rpx;
	border-radius: 30rpx;
	border: 1rpx solid #ff3f4a;
	font-size: 22rpx;
	color: #ff3f4a;
	margin-left: 12rpx;
	box-sizing: border-box;
	text-align: center;
}

.r_disable {
	padding: 14rpx 30rpx;
	border-radius: 30rpx;
	border: 1rpx solid #ccc;
	background: #ccc;
	font-size: 22rpx;
	color: #333;
	margin-left: 12rpx;
}

.disabled {
	color: rgba(0, 0, 0, 0.2);
	border-color: rgba(0, 0, 0, 0.2);
}

.tips2 {
	width: 600rpx;
	padding: 32rpx;
	background: #fff;
	border-radius: 32rpx;
	box-sizing: border-box;
	.title {
		padding-top: 12rpx;
		font-size: 36rpx;
		font-weight: bold;
		text-align: center;
		line-height: 50rpx;
	}
	.content {
		padding-top: 32rpx;
		text-align: center;
		font-size: 30rpx;
		color: #666;
		line-height: 42rpx;
	}
	.btn-group {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding-top: 66rpx;
	}
	.btn {
		width: 260rpx;
		height: 88rpx;
		line-height: 88rpx;
		font-size: 30rpx;
		text-align: center;
		border-radius: 10rpx;
	}
	.cancel {
		background: #f3f3f3;
		color: #333;
	}
	.confirm {
		background: #ebbe87;
		color: #fff;
	}
}
</style>
